package entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.time.LocalDateTime;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class User implements Serializable {

    @NotNull
    private Long id;

    @NotBlank(message = "用户名不能为空")
    private String username;

    @JsonIgnore//让springmvc把当前对象转成json字符串的时候，忽略password，最终的json字符串中就没有password这个属性了
    @NotBlank(message = "密码不能为空")
    @Pattern(regexp = "^\\S{1,10}$^")
    private String password;

    @NotBlank(message = "邮箱不能为空")
    @Email(message = "邮箱格式不正确")
    private String email;


    @ApiModelProperty("昵称")
    private String nickname;

    private String userPic;

    private LocalDateTime createTime;

    private LocalDateTime updateTime;

    private int loginRole;


}
